package com.adcdn.addemo.game;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.FrameLayout;

import com.adcdn.addemo.Constant;
import com.android.adcdn.sdk.utils.webview.view.AdcdnWebView;
import com.yunxia.addemo.R;


/**
 * @author : shenyp
 * @date : 2021/8/17
 * @description : 游戏广告demo
 */
public class GameActivity extends Activity {
    FrameLayout frameLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game);
        try {
            frameLayout = findViewById(R.id.flContainer);
            AdcdnWebView adcdnWebView = new AdcdnWebView(this);
            adcdnWebView.showGamePage(this, frameLayout, Constant.GAME_SN);
            adcdnWebView.setListener(new AdcdnWebView.Interactive() {
                @Override
                public void intentPath(String path, AdcdnWebView.ICallBackFunction function) {
                    // 可在开发者后台游戏配置自定义scheme
                    try {
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(path));
                        startActivity(intent);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static void jumpHere(Context context) {
        context.startActivity(new Intent(context, GameActivity.class));
    }
}
